<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试ajax以及restful风格</title>
    <script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
<form>
    编号：<input type="text" name="number" id="number"/><br/>
    金额：<input type="text" id="money" name="money"/><br/>
    <input type="button" value="登陆" onclick="login()"/><br/>
</form>
<H id="myDiv">666</H>
</body>
<script>
    function login() {
        var id=$("#number").val();
        $.ajax({
            url: "./user/user/"+id,
            type: "POST",
            //定义回调返回的数据格式为json,可以省略
            dataType:"json",
            success:function(data){
                if(data.username!=null){
                    alert(id+data.username+data.password);
                    //向所选的元素插入内容
                    $("#myDiv").append(data.username);
                    //向所选的元素改变内容
                    //$("#myDiv").html(data.username);
                }else {
                    alert("找不到");
                }
            }
        });
    }
</script>
</html>